package main

import (
	"fmt"
	"net/http"
	"os/exec"

	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()
	// 重启的路由 /restart
	r.GET("/restart", func(c *gin.Context) {
		cmd := exec.Command("killall", "-HUP", "appweiyigeek")
		err := cmd.Run()
		if err != nil {
			fmt.Println("Error executing restart command:", err)
			c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to restart Gin server."})
			return
		}
		c.JSON(http.StatusOK, gin.H{"message": "Gin server restarted successfully."})
	})

	r.Run(":8080")
}
